import request from "@/utils/request";

enum API {
  BookSave_URL = "/ebook/save",
  BookDelete_URL = "/ebook/delete/", // 修正拼写错误
  CategoryAll_URL = "/category/all", // 修正枚举名
}

export function useApi() {
  // 设备流量接口
  function flowList<T>(page: number = 1, size: number = 14): Promise<T> {
    return request<T>({
      url: "/deviceflow/getlist",
      method: "get",
      data: { page: page, size: size },
    });
  }
  // 设备流量查询接口
  //   function flowListQuery<T>(data): Promise<T> {
  //     return request<T>({
  //       url: "/DeviceflowvoController/ConditionalQuery",
  //       method: "get",
  //       data: data,
  //     });
  //   }
  function flowListQuery<T>(data): Promise<T> {
    return request<T>({
      url: "/flowvo/getDevicesByPages",
      method: "get",
      data: data,
    });
  }

  //压力设备接口
  function pressureList<T>(page: number = 1, size: number = 14): Promise<T> {
    return request<T>({
      url: "/devicepressure/getlist",
      method: "get",
      data: { page: page, size: size },
    });
  }
  //压力设备查询接口
  function pressureQuery<T>(data): Promise<T> {
    return request<T>({
      url: "/devicepressure/ConditionalQuery",
      method: "get",
      data: data,
    });
  }

  // 获取报修数据
  function repairList<T>(data: pageSizeReq): Promise<T> {
    return request<T>({
      url: "/repair/getlist",
      method: "get",
      data: data,
    });
  }

  // 报修数据添加
  function repairAdd<T>(data: RequireAddReq): Promise<T> {
    return request<T>({
      url: "/repair/add",
      method: "post",
      data: data,
    });
  }
  // 报修数据修改（用于维修者上传报修后状况）

  function repairUpdate<T>(data: RequireUpdateReq): Promise<T> {
    return request<T>({
      url: "/repair/update",
      method: "put",
      data: data,
    });
  }

  //电费信息列表获取
  function electricList<T>(page: number = 1, size: number = 14): Promise<T> {
    return request<T>({
      url: "/electricCharge/getlist",
      method: "get",
      data: { page: page, size: size },
    });
  }

  //添加电费信息
  function electricPay<T>(data: ElectricPayReq): Promise<T> {
    return request<T>({
      url: "/electricCharge/add",
      method: "post",
      data: data,
    });
  }

  return {
    flowList,
    pressureList,
    flowListQuery,
    pressureQuery,
    repairUpdate,
    repairAdd,
    repairList,
    electricList,
    electricPay,
  };
}
